package org.nimi317.web_gis.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.nimi317.web_gis.data.AreaCodeList;
import org.nimi317.web_gis.dao.StationMapper;
import org.nimi317.web_gis.entity.Area;
import org.nimi317.web_gis.entity.Station;
import org.nimi317.web_gis.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author nimi317
 * @since 2024-01-03
 */
@Service
public class StationServiceImpl extends ServiceImpl<StationMapper, Station> implements IStationService {

    @Autowired
    private AreaCodeList areaCodeList;

    @Override
    public void updateStationData() {
        List<Area> codes = areaCodeList.getAreaCodes();
        if (ObjectUtils.isNotEmpty(codes)) {
            for (Area code : codes) {
                areaCodeList.updateStation(code.getCityName(),code.getCityCode());
            }
        }
    }
}
